package com.changgou.seckill.mq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/*****
 * @Author: 黑马训练营
 * @Description: com.changgou.seckill.mq
 ****/
@Configuration
public class SeckillOrderConfig {

    /***
     * 创建一个交换机
     */
    @Bean
    public DirectExchange seckillOrderExchange(){
        return new DirectExchange("seckillOrderExchange",true,false);
    }
    /***
     * 创建一个队列
     */
    @Bean
    public Queue seckillOrderQueue(){
        return new Queue("seckillOrderQueue");
    }

    /***
     * 队列与交换机绑定
     */
    @Bean
    public Binding queueBindingExchange(Queue seckillOrderQueue, Exchange seckillOrderExchange){
        return BindingBuilder.bind(seckillOrderQueue).to(seckillOrderExchange).with("seckillOrderQueue").noargs();
    }
}
